public class Leetcode2006 {
    private static final int MAX_SIZE = 100;

    public static void main(String[] args) {

    }

    public int countKDifference(int[] nums, int k) {
        int[] hash = new int[MAX_SIZE + 1];
        for (int num : nums) {
            ++hash[num];
        }

        for (int i = 1; i + k <= MAX_SIZE; i++) {
            hash[0] += hash[i] * hash[i + k];
        }
        return hash[0];
    }
}
